package org.op.menu;

import org.op.editor.OpenCloseController;
import org.op.editor.SearchAndReplaceController;
import org.op.editor.SnipToController;
import org.op.editor.UndoRedoController;
import org.op.editor.doc.CuCoPaController;
import org.op.editor.doc.DocumentPersistController;
import org.op.editor.doc.EditorLoadController;
import org.op.looks.FontController;
import org.op.looks.SkinController;
import org.op.nav.DocumentNodeController;
import org.op.nav.FolderController;
import org.op.wword.AliasController;

public class MenuActionControllerImpl implements MenuActionController {

	private NotebookController notebookController;
	private EditorLoadController editorController;
	private CuCoPaController cucoController;
	private SkinController skinController;
	private FontController fontController;
	private DocumentPersistController docPersistController;
	private OpenCloseController openCloseController;
	private AliasController aliasController;
	private FolderController folderController;
	private SearchAndReplaceController sarController;
	private DocumentNodeController docNodeController;
	private UndoRedoController undoRedoController;
	private SnipToController snipToController;
	
	public void doAction(String menuItemName) {
		// Switch not supported with Strings
		if (menuItemName!=null) {
			if (menuItemName.equalsIgnoreCase("new.notebook")) {
				notebookController.newNotebook();
			}
			if (menuItemName.equalsIgnoreCase("open.notebook")) {
				notebookController.openNotebook();
			}
			if (menuItemName.equalsIgnoreCase("archive.notebook")) {
				notebookController.zipNotebook();
			}
			
			// wikiword actions
			if (menuItemName.equalsIgnoreCase("save.wikiword")) {
				docPersistController.saveDocument();
			}
			if (menuItemName.equalsIgnoreCase("save.as.wikiword")) {
				docPersistController.saveAsDocument();
			}
			if (menuItemName.equalsIgnoreCase("save.all")) {
				docPersistController.saveAllDocuments();
			}
			if (menuItemName.equalsIgnoreCase("new.wikiword")) {
				openCloseController.newDocument();
			}
			if (menuItemName.equalsIgnoreCase("open.wikiword")) {
				openCloseController.openDocument();
			}
			if (menuItemName.equalsIgnoreCase("close.wikiword")) {
				openCloseController.closeDocument();
			}
			if (menuItemName.equalsIgnoreCase("close.all")) {
				openCloseController.closeAllDocuments();
			}
			if (menuItemName.equalsIgnoreCase("exit.app")) {
				openCloseController.exitApplication();
			}
			
			// alias actions
			if (menuItemName.equalsIgnoreCase("alias.add")) {
				aliasController.addAlias();
			}
			if (menuItemName.equalsIgnoreCase("alias.edit")) {
				aliasController.editAlias();
			}			
			
			// cocopa actions
			if (menuItemName.equalsIgnoreCase("edit.cut")) {
				cucoController.cutToClipboard();
			}
			if (menuItemName.equalsIgnoreCase("edit.copy")) {
				cucoController.copyToClipboard();
			}
			if (menuItemName.equalsIgnoreCase("edit.paste")) {
				cucoController.pasteFromClipboard();
			}
			if (menuItemName.equalsIgnoreCase("edit.select.all")) {
				cucoController.selectAll();
			}
			if (menuItemName.equalsIgnoreCase("edit.clear.all")) {
				cucoController.clearAll();
			}
			
			// search and replace
			if (menuItemName.equalsIgnoreCase("edit.find")) {
				sarController.searchForText();
			}
			if (menuItemName.equalsIgnoreCase("edit.replace")) {
				sarController.replaceText();
			}
			
			// special actions
			if (menuItemName.equalsIgnoreCase("set.font")) {
				fontController.configureFonts();
			}
			if (menuItemName.equalsIgnoreCase("set.skin")) {
				skinController.configureSkin();
			}
			
			// folder actions
			if (menuItemName.equalsIgnoreCase("folder.add")) {
				folderController.addFolder();
			}
			if (menuItemName.equalsIgnoreCase("folder.trash")) {
				folderController.trashFolder();
			}
			if (menuItemName.equalsIgnoreCase("trash.wikiword")) {
				docNodeController.trashNote();
			}
			if (menuItemName.equalsIgnoreCase("add.wikiword")) {
				docNodeController.addNote();
			}
			if (menuItemName.equalsIgnoreCase("move.wikiword")) {
				docNodeController.moveNote();
			}

			// undo and redo
			if (menuItemName.equalsIgnoreCase("edit.undo")) {
				undoRedoController.undoLastEdit();
			}
			if (menuItemName.equalsIgnoreCase("edit.redo")) {
				undoRedoController.redoLastEdit();
			}
			
			// snip actions
			if (menuItemName.equalsIgnoreCase("snip.to.new")) {
				snipToController.snipToNew();
			}
			if (menuItemName.equalsIgnoreCase("snip.to.archive")) {
				snipToController.snipToArchive();
			}
			

		}
	}

	public NotebookController getNotebookController() {
		return notebookController;
	}

	public void setNotebookController(NotebookController notebookController) {
		this.notebookController = notebookController;
	}

	public EditorLoadController getEditorController() {
		return editorController;
	}

	public void setEditorController(EditorLoadController editorController) {
		this.editorController = editorController;
	}

	public CuCoPaController getCucoController() {
		return cucoController;
	}

	public void setCucoController(CuCoPaController cucoController) {
		this.cucoController = cucoController;
	}

	public SkinController getSkinController() {
		return skinController;
	}

	public void setSkinController(SkinController skinController) {
		this.skinController = skinController;
	}

	public FontController getFontController() {
		return fontController;
	}

	public void setFontController(FontController fontController) {
		this.fontController = fontController;
	}

	public DocumentPersistController getDocPersistController() {
		return docPersistController;
	}

	public void setDocPersistController(DocumentPersistController docPersistController) {
		this.docPersistController = docPersistController;
	}

	public OpenCloseController getOpenCloseController() {
		return openCloseController;
	}

	public void setOpenCloseController(OpenCloseController openCloseController) {
		this.openCloseController = openCloseController;
	}

	public AliasController getAliasController() {
		return aliasController;
	}

	public void setAliasController(AliasController aliasController) {
		this.aliasController = aliasController;
	}

	public FolderController getFolderController() {
		return folderController;
	}

	public void setFolderController(FolderController folderController) {
		this.folderController = folderController;
	}

	public SearchAndReplaceController getSarController() {
		return sarController;
	}

	public void setSarController(SearchAndReplaceController sarController) {
		this.sarController = sarController;
	}

	public DocumentNodeController getDocNodeController() {
		return docNodeController;
	}

	public void setDocNodeController(DocumentNodeController docNodeController) {
		this.docNodeController = docNodeController;
	}

	public UndoRedoController getUndoRedoController() {
		return undoRedoController;
	}

	public void setUndoRedoController(UndoRedoController undoRedoController) {
		this.undoRedoController = undoRedoController;
	}

	public SnipToController getSnipToController() {
		return snipToController;
	}

	public void setSnipToController(SnipToController snipToController) {
		this.snipToController = snipToController;
	}
	
}
